package top.xiaocao.jpa.service;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.xiaocao.jpa.model.Address;
import top.xiaocao.jpa.repository.AddressRepository;

@Service
public class AddressServiceImpl implements AddressService {
	
	@Autowired
	private AddressRepository addressRepository;

	@Override
	@Transactional
	public void add(Address address) {
		addressRepository.save(address);
	}

	@Override
	@Transactional
	public void addAndThrowException(Address address) {
		addressRepository.save(address);
		int i = 1;
		if (i == 1) {
			throw new RuntimeException("test exception");
		}
	}

}
